package com.biyao.controller.product;


import com.baomidou.mybatisplus.plugins.Page;
import com.biyao.schedulingcommon.response.BaseMsg;
import com.biyao.schedulingcommon.response.SuccessMsg;
import com.biyao.schedulingentity.product.ProductionPlanTemplateCopy;
import com.biyao.schedulingentity.product.ProductionPlanTemplateEntity;
import com.biyao.schedulingentity.product.TProductionPlanEntity;
import com.biyao.service.model.product.ProductionPlanIMessage;
import com.biyao.service.model.product.ProductionPlanMessage;
import com.biyao.service.model.product.ProductionPlanTemplateMessage;
import com.biyao.service.model.product.imp.TProductionPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * 
 *
 * @author code generator
 * @date 2019-09-16 09:44:18
 */
@Api(tags = {"生产计划模版"})
@RestController
@RequestMapping("api/v1/tproductionplan")
public class TProductionPlanController {

    @Autowired
    private TProductionPlanService tProductionPlanService;

    @Autowired
    private ProductionPlanTemplateMessage productionPlanTemplateMessage;

    @Autowired
    private ProductionPlanIMessage productionPlanMessage;

    @ApiOperation(value = "列表")
    @GetMapping
    public BaseMsg list(@RequestParam(defaultValue = "1") Integer pageNum,
                        @RequestParam(defaultValue = "10") Integer pageSize
    ) {
        Page page = tProductionPlanService.list(pageNum, pageSize);

        return new SuccessMsg(page);
    }

    @ApiOperation(value = "列表")
    @GetMapping("/detail/{id}")
    public BaseMsg listDetail(@PathVariable("id") Integer id
    ) {
        ProductionPlanTemplateCopy list = productionPlanTemplateMessage.selectProductionPlanTemplate(id);

        return new SuccessMsg(list);
    }


    @ApiOperation(value = "保存")
    @PostMapping
    public BaseMsg save(@RequestBody ProductionPlanTemplateEntity tProductionPlan) {
        Integer id=productionPlanTemplateMessage.addProductionPlanTemplate(tProductionPlan);
        return new SuccessMsg(id);
    }



    @ApiOperation(value = "更新")
    @PutMapping
    public BaseMsg update(@RequestBody ProductionPlanTemplateEntity tProductionPlan) {
        productionPlanTemplateMessage.updateProductPlanTemplate(tProductionPlan);
        return new SuccessMsg();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("delete/{id}")
    public BaseMsg delete(@PathVariable("id") Integer id) {
        productionPlanTemplateMessage.deleteProductPlanTemplate(id);
        return new SuccessMsg();
    }

    @ApiOperation("自动模式启动")
    @GetMapping("/selectProductionDetail/{id}")
    public BaseMsg selectProductionDetailAndJudgeIsImplementByProductId(@PathVariable("id") Integer id){
        return new SuccessMsg( productionPlanMessage.selectProductionDetailAndJudgeIsImplementByProductId(id));
    }
    @ApiOperation("自动模式启动另外一台天车")
    @GetMapping("/selectProductionDetail2/{id}")
    public BaseMsg selectProductionDetailAndJudgeIsImplementByProductIdT2(@PathVariable("id") Integer id){
        return new SuccessMsg( productionPlanMessage.selectProductionDetailAndJudgeIsImplementByProductIdT2(id));
    }

    @ApiOperation("自动模式自动翻译")
    @GetMapping("/translation/{id}")
    public BaseMsg translation(@PathVariable("id") Integer id){
        return new SuccessMsg(productionPlanMessage.selectProductTranslation(id));
    }

    @ApiOperation("自动模式自动翻译T2")
    @GetMapping("/translation2/{id}")
    public BaseMsg translation2(@PathVariable("id") Integer id){
        return new SuccessMsg(productionPlanMessage.selectProductionTranslationT2(id));
    }

    @ApiOperation("重置模版")
    @GetMapping("/reset/{id}")
    public BaseMsg reset(@PathVariable("id") Integer id){
        productionPlanMessage.resetProductionPlan(id);
        return new SuccessMsg();
    }

}
